﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;

namespace B2B.Models
{
    public class SP_ChiTietDonHang_SP
    {
        private int maSP;

        public int MaSP
        {
            get { return maSP; }
            set { maSP = value; }
        }
        private string tenSP;

        public string TenSP
        {
            get { return tenSP; }
            set { tenSP = value; }
        }
        private string hinhAnh;

        public string HinhAnh
        {
            get { return hinhAnh; }
            set { hinhAnh = value; }
        }
        private string baoGia;

        public string BaoGia
        {
            get { return baoGia; }
            set { baoGia = value; }
        }
        public SP_ChiTietDonHang_SP SP_ChiTietDH_SP(int maDH)
        {
            SP_ChiTietDonHang_SP ctDH_SP = new SP_ChiTietDonHang_SP();
            SqlConnection conn = KetNoi.Connection();
            SqlCommand cmd = new SqlCommand("SP_CHITIETDONHANG_SP", conn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@MADH", maDH);
            conn.Open();
            SqlDataReader reader = cmd.ExecuteReader();
            if (reader.Read())
            {
                ctDH_SP.MaSP = reader.GetInt32(0);
                ctDH_SP.TenSP = reader.GetString(1);
                ctDH_SP.HinhAnh = reader.GetString(2);
                ctDH_SP.BaoGia = reader.GetString(3); 
            }
            return ctDH_SP;

        }
    }
}